<?php

class Application_Form_ProductCategory extends Zend_Form
{
    private $view;
    public function init()
    {
        /* Form Elements & Other Definitions Here ... */
        $this->view = Zend_Layout::getMvcInstance()->getView();
        $this->setAttrib("id","category");
        // create id element
        $id = $this->createElement("hidden","id");
        $id->setDecorators(array("ViewHelper"));
        $this->addElement($id);
        
        
        //create element name
        $article_name = $this->createElement("text","name");
        $article_name->setLabel("Tên danh mục sản phẩm")
                     ->setRequired()
                     ->addValidators(array(
                        array("NotEmpty",false,array("messages"=>array('isEmpty'=>"Tên danh mục không được để trống."))),
                     ))
                     ->setAttrib("size","100");            
        $this->addElement($article_name);
        
        // Mô tả
        $description = $this->createElement("textarea","description");
        $description->setLabel("Mô tả danh mục")
                            ->setAttrib("rows",3)
                            ->setAttrib("style","width: 99%");
        $this->addElement($description);
        

        // create submit button
        $submit = $this->createElement("submit","submit");
        $submit->setLabel("Lưu")
               ->setAttrib("class","btn btn-black");
        $this->addElement($submit);

        
        // create submit button
        $reset = $this->createElement("reset","reset");
        $reset->setLabel("Nhập lại")
              ->setAttrib("class","btn btn-orange");
        $this->addElement($reset);
        
        // create submit button
        $link = $this->view->url(array(
            'module'=>"admin",
            'controller'=>"product-category",
            'action'=>"index"
        ));
        $cancel = $this->createElement("button","cancel");
        $cancel->setLabel("Quay lại")
               ->setAttrib("class","btn btn-red")
               ->setAttrib("onclick","window.location='$link'");
        $this->addElement($cancel);
    }
}

